#include<stdio.h>
#include<string.h>
struct node
{
	char a[10];
	char b[10];
	
}arr[10];
struct node1
{
	char a1[10];
	char b1[10];
	
}arr1[10];
void main()
{

FILE *fp;					
fp=fopen("final3.txt","w");			
int q;
char name[10];
char passwrd[10];
char name1[10];
char passwrd1[10];
int index,index1,key,key1;
int num,i=0,j=0,k=0;
printf("enter the no. of entries : ");
scanf("%d",&num);
for(i=0;i<num;i++)
{
printf("enter the user name : ");
scanf("%s",name);
printf("enter the password : ");
scanf("%s",passwrd);
index = name[0];
while(j!=10)
{
key = (index+j+j*j)%10;
if(strcmp(arr[key].a,"")==0)
{
strcpy(arr[key].a,name);

fprintf(fp,"%s",arr[key].a);			

strcpy(arr[key].b,passwrd);

fprintf(fp,"%s",arr[key].b);			

break;
}
else
{
j++;
}
}
}
printf("enter the username to search : ");
scanf("%s",name1);
index1 = name1[0];

while(k!=10)
{
key1 = (index +k + k*k)%10;
	if(strcmp(arr[key1].a,name1)==0)
	{	
		printf("enter password : ");						
		scanf("%s",passwrd1);
		if(strcmp(arr[key1].b,passwrd1)!=0)
		{
			printf("not valid\n");
		}
		else if(strcmp(arr[key1].b,passwrd1)==0)
		{
			printf("u r logged in \n");
			break;
		}
		
	} 
	else
	{
		k++;
	}
}
fclose(fp);
}
